<link rel="stylesheet" href="<?php echo Yii::app()->getBaseUrl()?>/css/datacard-tables.css" />
<style type="text/css">
form div.section > label {
	width:15% !important;
}
form div.section > div {
	margin-left:20% !important;
}
form div.section input.large{
	width:100%;
	max-width:60%;
}
form div.section textarea.large{
	width:100%;
	max-width:100%;
	height: 300px;
}
.wordwrap { 
   white-space: pre-wrap;      /* CSS3 */   
   white-space: -moz-pre-wrap; /* Firefox */    
   white-space: -pre-wrap;     /* Opera <7 */   
   white-space: -o-pre-wrap;   /* Opera 7 */    
   word-wrap: break-word;      /* IE */
}
</style>
<script src="<?php echo Yii::app()->getBaseUrl()?>/admin_assets/js/nicEdit.js" type="text/javascript"></script>
<script type="text/javascript">

	bkLib.onDomLoaded(function() { 
		nicEditors.allTextAreas({fullPanel : true, maxHeight :340, width : 747});
			//nicEditors.findEditor('english_desc').setContent('');
			$("div.nicEdit-main").addClass('wordwrap');
	});
</script>
		
<div class="one-column">
		 <?php 
        	$action = isset($model->id) ? Yii::app()->getBaseUrl().'/admin/datacard/update/id/'.$model->id : Yii::app()->getBaseUrl().'/admin/datacard/add';
            $form=$this->beginWidget('CActiveForm', array(
										'id'=>'validation',
	                    			//	'action'=>Yii::app()->request->baseUrl.$action,
									)); 
		 ?>
		<div class="tab_container" >
				<div class="form">
					<p class="note">Fields with <span class="required">*</span> are required.</p>
					<div class="section">
						<label>Menu Name<span>*</span></label>
						<div>
							<?php echo $form->textField($model,'title',array('class'=>'validate[required,minSize[2],maxSize[255]] large', 'id'=>'title')); ?>
							<?php echo $form->error($model,'title'); ?>
						</div>
					</div>
					
					<div class="section">
						<label>Slug<small>To display in URL</small></label>
						<div>
							<?php echo $form->textField($model,'slug',array('class'=>'validate[minSize[2],maxSize[255]] large', 'id'=>'slug')); ?>
							<?php echo $form->error($model,'slug'); ?>
						</div>
					</div>
					
					<div class="section">
						<label>Meta Title<span>*</span></label>
						<div>
							<?php echo $form->textField($model,'meta_title',array('class'=>'validate[required, minSize[2],maxSize[255]] large', 'id'=>'meta_title')); ?>
							<?php echo $form->error($model,'meta_title'); ?>
						</div>
					</div>
					
					<div class="section">
						<label>Meta Keywords<small>Enter multiple keywords separated by comma</small></label>
						<div>
							<?php echo $form->textField($model,'meta_keywords',array('class'=>'validate[minSize[2],maxSize[255]] large', 'id'=>'meta_keywords')); ?>
							<?php echo $form->error($model,'meta_keywords'); ?>
						</div>
					</div>
					
					<div class="section">
						<label>Meta Description</label>
						<div>
							<?php echo $form->textField($model,'meta_description',array('class'=>'validate[minSize[2]] large', 'id'=>'meta_description')); ?>
							<?php echo $form->error($model,'meta_description'); ?>
						</div>
					</div>
					
					<div class="section">
						<label>Content<span>*</span><small>Use Font: OpenSans</small></label>
						<div>
						<?php echo $form->textarea($model,'content', array('id'=>'english_desc', 'class' => 'large'));?>
						</div>
					</div>
	
					<div class="section">
						<label>Active<span>*</span></label>
						<div>
							<?php echo $form->checkbox($model, 'status', array('id'=>'cms_active_es', 'class'=>'chkbox', 'checked'=>'checked'));?>
							<?php echo $form->error($model,'active'); ?>
						</div>
					</div>
					
					<div class="section">
						<label>&nbsp;</label>
						<div><input type="submit" name="submit" id="submit" class="uibutton" value="Submit" /></div>
					</div>
				</div><!-- form -->
			<?php $this->endWidget(); ?>
<script>
	$(document).ready(function(){
		$('#title').on('keyup', function(){
			var enTitle = $(this).val();
			var slug = enTitle.replace(/[ ]/g,'-');
			var slug = slug.replace(/[&]/g,'and');
			if(slug.charAt(slug.length-1) == '-'){
				slug = slug.substring(0, slug.length - 1);
			}
			$('#slug').val(slug.toLowerCase());
		});
		
		$('form#validation').on('submit', function(e){
			
			var english_desc = nicEditors.findEditor('english_desc').getContent();

			if(english_desc == '<br>'){
				english_desc = '';
			}

			var $result = false;

			if(jQuery.trim(english_desc) == ''){
					showError('Content field is required',2000);
					$result = false;
			} else {
					$result = true;
			}
			if ($result == true){
				loading('processing',1);
				$('form#validation').submit();
				unloading();
			}
			else {
				return false;
			}
			return false;
		});
			
	});
</script>